﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Linq;

namespace APNS.NET
{

    // Represents a more complex alert. This contains an image, body and localizable string values
    public class ExtendedApnsAlert : ApnsAlert
    {

        public new string Body { get; set; }
        public string LocalizableActionKey { get; set; }
        public string LocalizableKey { get; set; }
        public List<String> LocalizableValues { get; private set; }
        public string LaunchImage { get; set; }

        public ExtendedApnsAlert()
            : base()
        {
            LocalizableValues = new List<string>();
        }

        protected internal override JToken ToJsonString()
        {
            JObject result = new JObject();

            if (!string.IsNullOrEmpty(Body))
                result["body"] = new JValue(Body);
            if (!string.IsNullOrEmpty(LocalizableActionKey))
                result["action-loc-key"] = new JValue(LocalizableActionKey);
            if (!string.IsNullOrEmpty(LocalizableKey))
                result["loc-key"] = new JValue(LocalizableKey);
            if (LocalizableValues.Count > 0)
                result["loc-args"] = new JArray(LocalizableValues.ToArray());
            if (!string.IsNullOrEmpty(LaunchImage))
                result["launch-image"] = new JValue(LaunchImage);

            return result;
        }


        

    }
}
